import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class AttributeCombiner {

    public static void main(String[] args) {
        String[][] attributes = {
                {"口味", "草莓味"}, {"口味", "西瓜味"}, {"口味", "水蜜桃味"},
                {"规格", "1L"}, {"规格", "500ml"}
        };

        List<List<String>> combinations = combineAttributes(attributes);

        // 打印结果
        for (List<String> combination : combinations) {
            System.out.println(combination);
        }
    }

    public static List<List<String>> combineAttributes(String[][] attributes) {
        Map<String, List<String>> attrMap = new HashMap<>();
        for (String[] attr : attributes) {
            attrMap.computeIfAbsent(attr[0], k -> new ArrayList<>()).add(attr[1]);
        }

        List<List<String>> combinations = new ArrayList<>();
        combine(0, new ArrayList<>(), new ArrayList<>(attrMap.entrySet()), combinations);

        return combinations;
    }

    private static void combine(int index, List<String> current, List<Map.Entry<String, List<String>>> entries, List<List<String>> result) {
        if (index == entries.size()) {
            result.add(new ArrayList<>(current));
            return;
        }

        Map.Entry<String, List<String>> entry = entries.get(index);
        for (String value : entry.getValue()) {
            current.add(entry.getKey() + ": " + value);
            combine(index + 1, current, entries, result);
            current.remove(current.size() - 1); // Backtrack
        }
    }
}